package li.kaeppe.travel.tracker.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name="BLOG_ENTRY")
@SequenceGenerator(name="SEQ_BLOGENTRY", sequenceName="BLOGENTRY_SEQUENCE")
public class BlogEntry {

	/* **************************************************** */
	/*                      CONSTANTS                       */
	/* **************************************************** */

	/**
	 * 
	 */
	private static final long serialVersionUID = -4669107292230212273L;

	/* **************************************************** */
	/*                     MEMBER FIELDS                    */
	/* **************************************************** */
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO, generator="SEQ_BLOGENTRY")
	long id;
	
	@OneToOne
	WayPoint wayPoint;
	
	@OneToOne
	Trip trip;
	
	@Column(length=4096)
	private String title;
	
	@Lob
	private String content;
		
	/* **************************************************** */
	/*                       CONSTRUCTOR                    */
	/* **************************************************** */
	
	public BlogEntry() {}
	
	public BlogEntry(WayPoint wayPoint, String title, String content) {
		this.setWayPoint(wayPoint);
		this.setTitle(title);
		this.setContent(content);
	}
	
	
	/* **************************************************** */
	/*                    PUBLIC METHODS                    */
	/* **************************************************** */

	/* **************************************************** */
	/*                   PROTECTED METHODS                  */
	/* **************************************************** */

	/* **************************************************** */
	/*                    PRIVATE METHODS                   */
	/* **************************************************** */

	/* **************************************************** */
	/*                  GETTERS AND SETTERS                 */
	/* **************************************************** */

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public WayPoint getWayPoint() {
		return wayPoint;
	}

	public void setWayPoint(WayPoint wayPoint) {
		this.wayPoint = wayPoint;
		this.setTrip(wayPoint.getTrip());
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Trip getTrip() {
		return trip;
	}

	private void setTrip(Trip trip) {
		this.trip = trip;
	}
		
}
